import http from "@/utils/request";
import type { IRes } from "@/interface/index";
interface IgetInfo extends IRes {
  data:{
    created: null,
    updated: null,
    userId: number,
    nickName: string,
    logo: string,
    sex: string,
    mobile: string,
    isWechat: string
  }
}
// 获取个人信息
export const getInfo = () => {
  return http.post<IgetInfo>('/api/xlx-sso/user/getInfo')
}
export interface IAccountQuotaData {
  created: string,
  updated: string,
  totalQuota: number,  // 总额度
  usedQuota: number,  //已使用额度
  currentBalance: number // 当前余额
}
interface IAccountQuotaResData extends IRes { // 继承 IRes
  data: IAccountQuotaData
}
// 用户账户总额度查询
export const getAccountQuota = () => {
  return http.get<IAccountQuotaResData>('/api/xlx-sso/account/getAccountQuota')
}
export interface IAccountItem {
  created: string,// 创建时间
  updated ?: string,
  serialNumber: string, //流水号
  consumption: number,//消耗量
  remarks: string, //备注
  type: number, //类型0充值 1消耗
  id: number
}
interface IAccountData {
  counts: number, //总条数
  pagesize: number,//每页显示数据
  pages: number, //总页数
  page: number,//第几页
  items: IAccountItem[]
}
interface IAccountDataRes extends IRes {
  data: IAccountData
}
// 账户明细
export const getAccount = (data: object) => {
  return http.get<IAccountDataRes>('/api/xlx-sso/account')
}
interface IHeadData extends IRes{
  data: string
}
//修改用户头像
export const loginReginfoHead = (data: FormData)=>{
  return http.post<IHeadData>('/api/xlx-sso/user/loginReginfo/head', data)
}
interface ICheckCode extends IRes{
  data: string
}
//修改密码-发送验证码验证身份
export const sendCheckCode = ()=>{
  return http.post<ICheckCode>('/api/xlx-sso/user/sendCheckCode')
}
//修改密码-验证码验证
export const modifyPasswordVerification = (verificationCode: string)=>{
  return http.post<ICheckCode>('/api/xlx-sso/user/modifyPasswordVerification', { verificationCode })
}
//修改密码
export const modifyPassword = (password: string, repassword: string)=>{
  return http.post<ICheckCode>('/api/xlx-sso/user/modifyPassword', { password, repassword })
}
//用户注销
export const userLogout = ()=>{
  return http.get<ICheckCode>('/api/xlx-sso/user/logout')
}